using DapperDemo.Api.Dtos;
using DapperDemo.Api.Services;
using Microsoft.AspNetCore.Mvc;

namespace DapperDemo.Api.Controllers;

[ApiController]
[Route("[controller]")]
public class OrdersController : ControllerBase
{
    private readonly IOrderService _orderService;

    public OrdersController(IOrderService orderService)
    {
        _orderService = orderService;
    }

    [HttpGet]
    public async Task<IEnumerable<OrderDto>> Get()
    {
        return await _orderService.QueryList<OrderDto>("SELECT id, name FROM `order`");
    }
}
